function __construct() { parent::__construct(__FILE__); // Remember this //creamos una categoria de test $this->load->model('category'); $parent_id = NULL; $cat_attributes = array('name' => 'TEST_name', 'category_id' => $parent_id); Category::create($cat_attributes); $this->m_category = Category::find_by_id(Category::last()->id); $this->load->model('product'); //buscamos cuantos productos hay de dicha categoria $this->m_category_products_count = Product::count_by_category_id($this->m_category->id); }
function edit($id = FALSE, $parent_id = FALSE) { //load block submit helper and append in the head $this->template->append_metadata(block_submit_button()); //Rules for validation $this->_set_rules('edit'); //get the parent id and sanitize $parent_id = $this->uri->segment(5) ? $this->uri->segment(5) : $this->input->post('parent_id', TRUE); $parent_id = $parent_id != 0 ? filter_var($parent_id, FILTER_VALIDATE_INT) : NULL; //get the $id and sanitize $id = $this->uri->segment(4) ? $this->uri->segment(4) : $this->input->post('id', TRUE); $id = $id != 0 ? filter_var($id, FILTER_VALIDATE_INT) : NULL; //redirect if it´s no correct if (!$id) { $this->session->set_flashdata('message', array('type' => 'warning', 'text' => lang('web_object_not_exit'))); redirect('admin/categories/'); } //create control variables $this->template->title(lang("web_category_edit")); $this->template->set('category', Category::find_by_id($id)); $this->template->set('updType', 'edit'); $this->template->set('parent_id', $parent_id); if ($this->form_validation->run() == FALSE) { //load the view and the layout $this->template->build('categories/create'); } else { // build array for the model $form_data = array('name' => $this->input->post('name', TRUE), 'id' => $this->input->post('id', TRUE)); //find the item to update $category = Category::find($this->input->post('id', TRUE)); $category->update_attributes($form_data); // run insert model to write data to db if ($category->is_valid()) { $this->session->set_flashdata('message', array('type' => 'success', 'text' => lang('web_edit_success'))); redirect('admin/categories/' . $parent_id); } if ($category->is_invalid()) { $this->session->set_flashdata('message', array('type' => 'error', 'text' => $category->errors->full_messages())); redirect('admin/categories/' . $parent_id); } } }
protected function set_up_display() { if (isset($this->category_id)) { $category = Category::find_by_id((int) $this->category_id); $this->category = $category->category; // $this->unit_price = $category->unit_price; $this->price = $this->unit_price * $this->quantity; $this->price_company = $this->company_unit_price * $this->quantity; if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { $formatter = new NumberFormatter('en_CH', NumberFormatter::CURRENCY); $this->price = $formatter->formatCurrency($this->price, 'CHF'); $this->price_company = $formatter->formatCurrency($this->price_company, 'CHF'); // $this->unit_price=$formatter->formatCurrency($this->unit_price, 'CHF'); // $this->company_unit_price=$formatter->formatCurrency($this->company_unit_price, 'CHF'); } } if (isset($this->project_id)) { $project = Project::find_by_id((int) $this->project_id); $this->project_code = $project->project_code; } }
<?php /** cat */ $category_url = return_url(); $current_category = !empty($category_url[1]) ? $category_url[1] : 0; $job_by_cats = JobCategory::top_ten_cat($current_category); if ($job_by_cats) { $categorys = array(); $i = 0; foreach ($job_by_cats as $job_by_cat) { $job_id = $job_by_cat->job_id; $cat_id = $job_by_cat->category_id; $total_jobs = JobCategory::get_total_job_by_cat($cat_id); if (Job::find_active_job_by_id($job_id)) { $cat_name = Category::find_by_id($cat_id); /**check length of text */ $cat_names = strlen($cat_name->cat_name) > 25 ? substr($cat_name->cat_name, 0, 25) . " ... " : $cat_name->cat_name; $categorys[$i]['var_name'] = $cat_name->var_name; $categorys[$i]['category_name'] = $cat_names; $categorys[$i]['f_category_name'] = $cat_name->cat_name; $categorys[$i]['total_num'] = $total_jobs; $i++; } } $smarty->assign('job_by_cats', $categorys); $smarty->assign('job_by_categorys', $smarty->fetch('job_by_top_categorys.tpl')); }
function display_content_box_header($portal_id, $topic_id, $sub_topic_1_id, $sub_topic_2_id, $sub_topic_3_id, $sub_topic_4_id, $category_id) { if ($category_id != 156) { $category = Category::find_by_id($category_id); $category_title = $category->category_title; $output = "<h2>{$category_title}</h2>"; } elseif ($sub_topic_4_id != 156) { $sub_topic_4 = SubTopic4::find_by_id($sub_topic_4_id); $sub_topic_4_title = $sub_topic_4->sub_topic_4; $output = "<h2>{$sub_topic_4_title}</h2>"; } elseif ($sub_topic_3_id != 156) { $sub_topic_3 = SubTopic3::find_by_id($sub_topic_3_id); $sub_topic_3_title = $sub_topic_3->sub_topic_3; $output = "<h2>{$sub_topic_3_title}</h2>"; } elseif ($sub_topic_2_id != 156) { $sub_topic_2 = SubTopic2::find_by_id($sub_topic_2_id); $sub_topic_2_title = $sub_topic_2->sub_topic_2; $output = "<h2>{$sub_topic_2_title}</h2>"; } elseif ($sub_topic_1_id != 156) { $sub_topic_1 = SubTopic1::find_by_id($sub_topic_1_id); $sub_topic_1_title = $sub_topic_1->sub_topic_1; $output = "<h2>{$sub_topic_1_title}</h2>"; } elseif ($topic_id != 156) { $topic = Topic::find_by_id($topic_id); $topic_title = $topic->topic; $output = "<h2>This week in {$topic_title}</h2>"; } elseif ($portal_id != 156) { $portal = Portal::find_by_id($portal_id); $portal_title = $portal->portal; $output = "<h2>This week in {$portal_title}</h2>"; } else { $output = "<h2>This week in RazaWeb</h2>"; } return $output; }
<section class="mainContent"> <div class="productRow" id="productRow"> <?php foreach ($products as $product) { ?> <article class="productInfo"><!-- Each individual product description --> <div><img src="../../<?php echo $product->image_path(); ?> "/></div> <p class="price"><?php echo $product->name; ?> </p> <p class="productContent"><?php $cat = Category::find_by_id($product->cat_id); echo $cat->get_name(); ?> </p> <p class="productContent"><?php $user = User::find_by_id($product->userid); echo $user->full_name(); ?> </p> </article> <?php } ?> </div> <div id="pagination" style="clear: both;"> <?php
$categories = Category::find_by_id($cv_details->recent_industry_work); $riw = $categories ? $categories->cat_name : format_lang('none'); $smarty->assign('riw', $riw); $careers = CareerDegree::find_by_id($cv_details->recent_career_level); $rcl = $careers ? $careers->career_name : format_lang('none'); $smarty->assign('careers', $rcl); //what are you looking for $ljt = $cv_details->look_job_title; $smarty->assign('ljt', $ljt); $ljt2 = $cv_details->look_job_title2; $smarty->assign('ljt2', $ljt2); $sql = " SELECT * FROM " . TBL_CV_CAT . " WHERE cv_id=" . $id; $cv_cat = $db->query($sql); $cv_cat_array = array(); while ($row = $db->fetch_object($cv_cat)) { $categories = Category::find_by_id($row->category_id); $cv_cat_array[] = $categories->cat_name; } $smarty->assign('li', join("<br />", $cv_cat_array)); //job states $js = empty($cv_details->look_job_status) ? 0 : $cv_details->look_job_status; $job_status = JobStatus::find_by_id($js); $ljs = $job_status ? $job_status->status_name : format_lang('none'); $smarty->assign('ljs', $ljs); //job type $job_t = empty($cv_details->look_job_type) ? 0 : $cv_details->look_job_type; $job_type_arr = JobType::find_by_id($job_t); //print_r( $job_type_arr); $job_types = $job_type_arr ? $job_type_arr->type_name : format_lang('none'); $smarty->assign('job_type', $job_types); //where do you wont to work
<?php require_once "../initialise_files.php"; include_once "sessioninc.php"; $smarty->assign('action', $_GET['action']); $smarty->assign('id', (int) $_GET['id']); if (isset($_GET['action']) && $_GET['action'] == "edit" && isset($_GET['id'])) { $id = (int) $_GET['id']; $cat_ = Category::find_by_id($id); $cat_name = strip_tags($cat_->cat_name); $smarty->assign('cat_name', $cat_name); if (isset($_GET['bt_update'])) { $category = new Category(); $category->id = (int) $_GET['id']; $category->var_name = $category->mod_write_check($_GET['txt_cat_name'], $cat_->var_name); $category->cat_name = $_GET['txt_cat_name']; if ($category->save()) { $session->message("category updated "); redirect_to($_SERVER['PHP_SELF'] . "?#" . $_GET['id']); die; } else { $message = join("<br />", $category->errors); } } } if (isset($_GET['action']) && $_GET['action'] == "delete" && isset($_GET['id'])) { $category = new Category(); $category->id = (int) $_GET['id']; if ($category->delete()) { $session->message("category deleted "); redirect_to($_SERVER['PHP_SELF'] . "?#" . $_GET['id']);
if (isset($_GET[$name])) { $value = $_GET[$name]; } else { isset($get_item) ? $value = $get_item->{$name} : ($value = $date); } echo $class_name::get_form($name, $value); $name = 'quantity'; if (isset($_GET[$name])) { $value = $_GET[$name]; } else { isset($get_item) ? $value = $get_item->{$name} : ($value = "1"); } echo $class_name::get_form($name, $value); if (isset($_GET['category_id'])) { $value_get = $_GET['category_id']; $categ = Category::find_by_id($_GET['category_id']); } $name = 'unit_price'; if (isset($_GET[$name])) { $value = $_GET[$name]; } else { isset($get_item) ? $value = $get_item->{$name} : ($value = ""); } if ($categ) { $value = $categ->{$name}; } echo $class_name::get_form($name, $value); $name = 'company_unit_price'; if (isset($_GET[$name])) { $value = $_GET[$name]; } else {
/** * Удаление категории */ public function delete() { if (!Request::ajax()) { App::redirect('/'); } if (!User::isAdmin()) { App::abort(403); } $errors = ''; $id = Request::input('id'); if ($category = Category::find_by_id($id)) { $category->token = Request::input('token', true); if ($category->is_valid() && $category->delete()) { exit(json_encode(['status' => 'ok'])); } else { $errors = $category->getErrorsText(); } } exit(json_encode(['status' => 'error', 'errors' => $errors])); }
function getCategoryWeb() { if (isset($_POST['cat_id'])) { $category = Category::find_by_id($_POST['cat_id']); return $category; } }
public function deleteProduct($id) { $category = Category::find_by_id($id); if ($category->delete()) { $_SESSION['adminmessage'] == "Deleted Successfully"; return true; } else { $_SESSION['adminmessage'] == "Delete not successfully, try again"; return true; } }