Example #1
0
/**
* @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> &raquo; <a href='./clients.php'>" . __('Customers', 'works') . "</a> &raquo;" . ($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();
}
Example #2
0
/**
* @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> &raquo; <a href='./types.php'>" . __('Customer types', 'works') . "</a> &raquo; " . ($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();
}
Example #3
0
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> &raquo; \n\t\t<a href='categos.php'>" . __('Categories', 'works') . '</a> &raquo; ' . ($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();
}
 /**
  * Get works based on given parameters
  */
 public function get_works($limit, $category = null, $public = 1, $object = true, $order = "created DESC")
 {
     global $xoopsModule, $xoopsModuleConfig;
     include_once XOOPS_ROOT_PATH . '/modules/works/class/pwwork.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/works/class/pwcategory.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/works/class/pwclient.class.php';
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE public={$public}";
     $sql .= $category > 0 ? " AND catego='{$category}'" : '';
     $sql .= $order != '' ? " ORDER BY {$order}" : '';
     $sql .= " LIMIT 0,{$limit}";
     if ($xoopsModule && $xoopsModule->dirname() == 'works') {
         $mc =& $xoopsModuleConfig;
     } else {
         $mc = RMUtilities::module_config('works');
     }
     $result = $db->query($sql);
     $works = array();
     while ($row = $db->fetchArray($result)) {
         $work = new PWWork();
         $work->assignVars($row);
         $ret = array();
         if (!isset($categos[$work->category()])) {
             $categos[$work->category()] = new PWCategory($work->category());
         }
         if (!isset($clients[$work->client()])) {
             $clients[$work->client()] = new PWClient($work->client());
         }
         $ret = array('id' => $work->id(), 'title' => $work->title(), 'desc' => $work->descShort(), 'catego' => $categos[$work->category()]->name(), 'client' => $clients[$work->client()]->name(), 'link' => $work->link(), 'created' => formatTimeStamp($work->created(), 's'), 'created_time' => $work->created(), 'image' => XOOPS_UPLOAD_URL . '/works/ths/' . $work->image(), 'rating' => PWFunctions::rating($work->rating()), 'featured' => $work->mark(), 'linkcat' => $categos[$work->category()]->link(), 'metas' => $work->get_metas());
         if ($object) {
             $w = new stdClass();
             foreach ($ret as $var => $value) {
                 $w->{$var} = $value;
             }
             $works[] = $w;
         } else {
             $works[] = $ret;
         }
     }
     return $works;
 }
Example #5
0
//Obtenemos los trabajos recientes
$sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE public=1 ORDER BY created DESC LIMIT {$start},{$limit}";
$result = $db->query($sql);
// Numero de resultados en esta página
$t = $db->getRowsNum($result);
$tpl->assign('page_total', $t);
$tpl->assign('per_col', ceil($t / 2));
$categos = array();
$clients = array();
while ($row = $db->fetchArray($result)) {
    $recent = new PWWork();
    $recent->assignVars($row);
    if (!isset($categos[$recent->category()])) {
        $categos[$recent->category()] = new PWCategory($recent->category());
    }
    if (!isset($clients[$recent->client()])) {
        $clients[$recent->client()] = new PWClient($recent->client());
    }
    $tpl->append('works', array('id' => $recent->id(), 'title' => $recent->title(), 'desc' => $recent->descShort(), 'catego' => $categos[$recent->category()]->name(), 'client' => $clients[$recent->client()]->businessName(), 'link' => $recent->link(), 'created' => formatTimeStamp($recent->created(), 's'), 'image' => XOOPS_UPLOAD_URL . '/works/ths/' . $recent->image(), 'rating' => PWFunctions::rating($recent->rating()), 'featured' => $recent->mark(), 'linkcat' => $categos[$recent->category()]->link(), 'metas' => $recent->get_metas()));
}
$tpl->assign('lang_works', __('Our Work', 'works'));
$tpl->assign('lang_catego', __('Cetegory:', 'works'));
$tpl->assign('lang_date', __('Date:', 'works'));
$tpl->assign('lang_client', __('Customer:', 'works'));
$tpl->assign('lang_allsrecent', __('View all recent works', 'works'));
$tpl->assign('link_recent', PW_URL . ($mc['urlmode'] ? '/recent/' : '/recent.php'));
$tpl->assign('link_featured', PW_URL . ($mc['urlmode'] ? '/featured/' : '/featured.php'));
$thSize = $mc['image_ths'];
$tpl->assign('width', $thSize[0] + 10);
$tpl->assign('lang_featured', __('Featured', 'works'));
include 'footer.php';
Example #6
0
/**
* @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() . ' &raquo; ' . __('Work Images', 'works'));
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> &raquo; <a href='./images.php?work=" . $work->id() . "'>" . __('Work Images', 'works') . "</a> &raquo;" . ($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();
}
Example #7
0
 public function get_metas()
 {
     if (empty($this->metas)) {
         $this->metas = PWFunctions::work_metas($this->id());
     }
     return $this->metas;
 }
Example #8
0
<?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));
Example #9
0
}
$tpl->assign('lang_desc', __('Description', 'works'));
$tpl->assign('lang_catego', __('Category', 'works'));
$tpl->assign('lang_client', __('Customer', 'admin_works'));
$tpl->assign('lang_start', __('Begins', 'works'));
$tpl->assign('lang_period', __('Time length', 'works'));
$tpl->assign('lang_comment', __('Comment', 'works'));
$tpl->assign('lang_cost', __('Price', 'works'));
$tpl->assign('lang_others', __('Related Works', 'works'));
$tpl->assign('lang_date', __('Date', 'works'));
$tpl->assign('lang_images', __('Work Images', 'works'));
$tpl->assign('lang_site', __('Web site', 'works'));
$tpl->assign('lang_mark', __('Featured', 'works'));
$tpl->assign('lang_rating', __('Our Rate', 'works'));
$tpl->assign('works_type', $mc['other_works']);
$tpl->assign('lang_views', __('Views', 'works'));
$imgSize = $mc['image_main'];
$thsSize = $mc['image_ths'];
$tpl->assign('widthimg', $thsSize[0] + 10);
$tpl->assign('widthOther', $thsSize[0] + 20);
PWFunctions::makeHeader();
RMFunctions::get_comments('works', 'work=' . $work->id());
// Comments form
RMFunctions::comments_form('works', 'work=' . $work->id(), 'module', PW_ROOT . '/class/workscontroller.php');
// Professional Works uses LightBox plugin to show
// work images.
if (RMFunctions::plugin_installed('lightbox')) {
    RMLightbox::get()->add_element('#pw-work-images a');
    RMLightbox::get()->render();
}
include 'footer.php';
Example #10
0
/**
* 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> &raquo; " . __('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();
}