/** * @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(); }
//Verificamos si el trabajo existe $work = new PWWork($id); if ($work->isNew()) { redirect_header(PW_URL . '/', 2, __('Specified id does not exists!', 'works')); die; } if (!$work->isPublic() && !($xoopsUser && $xoopsUser->isAdmin())) { redirect_header(PW_URL, 1, __('The requested content is not available!', 'works')); die; } if (!$work->isPublic()) { $xoopsTpl->assign('lang_preview', __('You are in preview mode! This work is hidden for all other users.', 'works')); } $cat = new PWCategory($work->category()); $client = new PWClient($work->client()); $work_data = array('id' => $work->id(), 'title' => $work->title(), 'desc' => $work->desc(), 'intro' => $work->descShort(), 'category' => array('name' => $cat->name(), 'description' => $cat->desc(), 'id' => $cat->id(), 'nameid' => $cat->nameId(), 'link' => $cat->link()), 'client' => $client->businessName(), 'site' => $work->nameSite(), 'url' => formatURL($work->url()), 'created' => formatTimeStamp($work->created(), 's'), 'start' => formatTimeStamp($work->start(), 's'), 'period' => $work->period(), 'cost' => $mc['cost'] ? sprintf($mc['format_currency'], number_format($work->cost(), 2)) : '', 'mark' => $work->mark(), 'image' => XOOPS_UPLOAD_URL . '/works/' . $work->image(), 'thumb' => XOOPS_UPLOAD_URL . '/works/ths/' . $work->image(), 'comment' => $work->comment(), 'rating' => PWFunctions::rating($work->rating()), 'views' => $work->views(), 'metas' => $work->get_metas(), 'public' => $work->isPublic(), 'link' => $work->link()); $work_data = RMEvents::get()->run_event('works.work.data<{$work.l}', $work_data, $work); $xoopsTpl->assign('work', $work_data); $work->addView(); //Obtenemos todas las imágenes del trabajo $sql = "SELECT * FROM " . $db->prefix('pw_images') . " WHERE work=" . $work->id(); $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $img = new PWImage(); $img->assignVars($row); $tpl->append('images', array('id' => $img->id(), 'image' => XOOPS_UPLOAD_URL . '/works/ths/' . $img->image(), 'title' => $img->title(), 'desc' => $img->desc(), 'link_image' => XOOPS_UPLOAD_URL . '/works/' . $img->image())); } RMEvents::get()->run_event('works.load.work.images', $work); $tpl->assign('xoops_pagetitle', $work->title() . ' » ' . $mc['title']); /** * Otros trabajos