コード例 #1
0
ファイル: clients.php プロジェクト: laiello/bitcero-modules
/**
* @desc Visualiza todos los clientes
**/
function showClients()
{
    global $xoopsModule, $xoopsSecurity;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_clients');
    list($num) = $db->fetchRow($db->query($sql));
    $page = rmc_server_var($_GET, 'page', 1);
    $limit = 15;
    $tpages = ceil($num / $limit);
    $page = $page > $tpages ? $tpages : $page;
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url('clients.php?page={PAGE_NUM}');
    $sql = "SELECT * FROM " . $db->prefix('pw_clients') . " ORDER BY id_client";
    $sql .= " LIMIT {$start},{$limit}";
    $result = $db->query($sql);
    $customers = array();
    while ($rows = $db->fetchArray($result)) {
        $client = new PWClient();
        $client->assignVars($rows);
        $type = new PWType($client->type());
        $customers[] = array('id' => $client->id(), 'name' => $client->name(), 'business' => $client->businessName(), 'type' => $type->type(), 'description' => $client->desc());
    }
    // Event
    $customers = RMEvents::get()->run_event('works.list.customers', $customers);
    PWFunctions::toolbar();
    RMTemplate::get()->add_style('admin.css', 'works');
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> &raquo; " . __('Customers', 'works'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Customers', 'works'));
    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 customers?', 'works') . "';\n\n        var pw_select_message = '" . __('You must select some customer before to execute this action!', 'works') . "';</script>");
    xoops_cp_header();
    include RMTemplate::get()->get_template('admin/pw_clients.php', 'module', 'works');
    xoops_cp_footer();
}
コード例 #2
0
ファイル: pw_works.php プロジェクト: laiello/bitcero-modules
function pw_works_edit($options)
{
    global $db;
    include_once XOOPS_ROOT_PATH . '/modules/works/class/pwclient.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/works/class/pwcategory.class.php';
    //Tipo de Trabajo
    $form = new RMForm(__('Block Options', 'works'), 'form_options', '');
    $ele = new RMFormSelect(__('Works type', 'works'), 'options[0]');
    $ele->addOption(0, __('Reandom works', 'works'), $options[0] == 0 ? 1 : 0);
    $ele->addOption(1, __('Featured works', 'works'), $options[0] == 1 ? 1 : 0);
    $ele->addOption(2, __('Recent works', 'works'), $options[0] == 2 ? 1 : 0);
    $form->addElement($ele);
    //Obtenemos las categorías
    $ele = new RMFormSelect(__('Category', 'works'), 'options[1]');
    $ele->addOption(0, __('All categories', 'works'));
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $result = $db->query("SELECT * FROM " . $db->prefix('pw_categos') . " WHERE active=1");
    while ($row = $db->fetchArray($result)) {
        $cat = new PWCategory();
        $cat->assignVars($row);
        $ele->addOption($cat->id(), $cat->name(), $options[1] == $cat->id() ? 1 : 0);
    }
    $form->addElement($ele, true);
    //Obtenemos los clientes
    $ele = new RMFormSelect(__('Customer', 'works'), 'options[2]');
    $ele->addOption(0, __('All customers', 'works'));
    $result = $db->query("SELECT * FROM " . $db->prefix('pw_clients'));
    while ($row = $db->fetchArray($result)) {
        $client = new PWClient();
        $client->assignVars($row);
        $ele->addOption($client->id(), $client->name(), isset($ptions[2]) ? $options[2] == $client->id() ? 1 : 0 : 0);
    }
    $form->addElement($ele, true);
    //Número de trabajos
    $form->addElement(new RMFormText(__('Works number', 'works'), 'options[3]', 5, 5, isset($options[3]) ? $options[3] : ''), true);
    $form->addElement(new RMFormText(__('Columns', 'works'), 'options[4]', 5, 5, isset($options[4]) ? $options[4] : ''), true);
    $form->addElement(new RMFormYesno(__('Show work image', 'works'), 'options[5]', isset($options[5]) ? $options[5] ? 1 : 0 : 0), true);
    $form->addElement(new RMFormYesno(__('Show description', 'works'), 'options[6]', isset($options[6]) ? $options[6] ? 1 : 0 : 0), true);
    return $form->render(false);
}