} $vals['letter'] = L10n::getinitial($vals['name']); if (!empty($vals['description'])) { $vals['description'] = stripcslashes($vals['description']); } if (!empty($_FILES['pic']['name'])) { $attachment->upload_process(); $vals['picture'] = $attachment->file_full_url; } if (!empty($id)) { $result = $brand->save($vals, "update", $id); } else { $result = $brand->save($vals); } if (!$result) { flash(); } $cache->updateIndexCache(); } if (isset($_GET['q'])) { $conditions[] = "Brand.name like '%" . $_GET['q'] . "%'"; } setvar("Brandtypes", $_PB_CACHE['brandtype']); $amount = $brand->findCount(null, $conditions); $joins[] = "LEFT JOIN {$tb_prefix}companies c ON c.id=Brand.company_id"; $page->setPagenav($amount); $fields = "Brand.id,c.name AS companyname,Brand.name AS name,Brand.alias_name AS aliasname,Brand.type_id AS type_id,Brand.if_commend"; $result = $brand->findAll($fields, $joins, $conditions, "Brand.id DESC", $page->firstcount, $page->displaypg); uaAssign(array("ByPages" => $page->pagenav)); setvar("Items", $result); template($tpl_file);
$id = intval($_GET['id']); } if ($do == "del" && !empty($id)) { $result = $brand->del(intval($id), "member_id=" . $_SESSION['MemberID']); } if ($do == "edit") { if (!empty($id)) { $brand_info = $pdb->GetRow("SELECT * FROM {$tb_prefix}brands WHERE member_id=" . $_SESSION['MemberID'] . " AND id={$id}"); if (!empty($brand_info['picture'])) { $brand_info['image'] = pb_get_attachmenturl($brand_info['picture'], "../"); } setvar("item", $brand_info); } setvar("BrandtypeOptions", $brandtypes->getTypeOptions()); $tpl_file = "brand_edit"; template($tpl_file); exit; } } $conditions[] = "member_id=" . $_SESSION['MemberID']; $amount = $brand->findCount('', $conditions, "id"); $page->setPagenav($amount); $result = $brand->findAll("id,name,description,picture", '', $conditions, "id DESC", $page->firstcount, $page->displaypg); if (!empty($result)) { for ($i = 0; $i < count($result); $i++) { $result[$i]['image'] = pb_get_attachmenturl($result[$i]['picture'], '../', "middle"); } setvar("Items", $result); setvar("ByPages", $page->pagenav); } template($tpl_file);