function admin_my_profile($user_id = null) { $this->layout = "backend/backend"; $this->set("title_for_layout", MY_PROFILE); $user_id = !empty($user_id) ? DECRYPT_DATA($user_id) : $this->Session->read("Auth.User.id"); App::import("Model", "User"); $this->User = new User(); if (!empty($this->data)) { $data = $this->data; $data['User']['id'] = DECRYPT_DATA($data['User']['id']); $data['UserProfile']['id'] = DECRYPT_DATA($data['UserProfile']['id']); $errors = $this->User->validate_add_user($data); if (count($errors) == 0) { $user_id = $this->User->save_user($data); if ($user_id != "") { $this->Session->setFlash(RECORD_SAVE, 'message/green'); $this->redirect(array('controller' => 'users', 'action' => 'user_listing', "admin" => true)); } else { $this->Session->setFlash(RECORD_ERROR, 'message/red'); $this->redirect(array('controller' => 'dashboards', 'action' => 'my_profile', ENCRYPT_DATA($this->data['User']['id']), "admin" => true)); } } else { $this->set("errors", $errors); } } else { if (isset($user_id)) { if ($this->is_id_exist($user_id, "User")) { $this->User->id = $user_id; $data = $this->User->read(); $data['User']['id'] = ENCRYPT_DATA($data['User']['id']); $data['UserProfile']['id'] = ENCRYPT_DATA($data['UserProfile']['id']); $this->data = $data; } else { $this->Session->setFlash(NOT_FOUND_ERROR, 'message/red'); $this->redirect(array('controller' => 'users', 'action' => 'user_listing', 'admin' => true)); exit; } } } }
function admin_validate_add_role_ajax() { $this->layout = ""; $this->autoRender = false; if ($this->RequestHandler->isAjax()) { $errors_msg = null; $data = $this->data; if (isset($this->data['Role']['id'])) { $data['Role']['id'] = DECRYPT_DATA($data['Role']['id']); } App::import("model", "Role"); $this->Role = new Role(); $errors = $this->Role->validate_add_role($data); if (is_array($this->data)) { foreach ($this->data['Role'] as $key => $value) { if (array_key_exists($key, $errors)) { foreach ($errors[$key] as $k => $v) { $errors_msg .= "error|{$key}|{$v}"; } } else { $errors_msg .= "ok|{$key}\n"; } } if (array_key_exists("RolePermission", $errors)) { $errors_msg .= "error|RolePermission|" . $errors['RolePermission'][0]; } } echo $errors_msg; exit; } }
function admin_validate_data_ajax() { $this->layout = ""; $this->autoRender = false; if ($this->RequestHandler->isAjax()) { $errors_msg = null; $data = $this->data; if (isset($this->data['Vendor']['id'])) { $data['Vendor']['id'] = DECRYPT_DATA($data['Vendor']['id']); } $errors = $this->Vendor->validate_data($data); if (is_array($this->data)) { foreach ($this->data['Vendor'] as $key => $value) { if (array_key_exists($key, $errors)) { foreach ($errors[$key] as $k => $v) { $errors_msg .= "error|{$key}|{$v}"; } } else { $errors_msg .= "ok|{$key}\n"; } } } echo $errors_msg; die; } }
function admin_search($action = null, $id = null) { $this->layout = ""; $this->autoRender = false; if ($this->RequestHandler->isAjax()) { //if(1){ $user = $this->Auth->user(); if (!empty($action)) { if ($user['role_id'] == 2 || $user['role_id'] == 3) { $dealer_id = $user['id']; $Dealerlimit = $this->admin_couponlimit($dealer_id); if (is_array($Dealerlimit) && !empty($Dealerlimit) && $Dealerlimit['action'] && $Dealerlimit['price_coupon_limit'] != 0) { $price_coupon_limit = $Dealerlimit['price_coupon_limit']; switch ($action) { case 'category': $set_categorydata = array(); if (!empty($id)) { $vendor_id = DECRYPT_DATA($id); App::import("Model", "Vendor"); $this->Vendor = new Vendor(); $validID = $this->Vendor->find('count', array("fields" => array('id'), "conditions" => array("Vendor.id" => $vendor_id))); if ($validID > 0) { App::import("Model", "Category"); $this->Category = new Category(); App::import("Model", "Product"); $this->Product = new Product(); $product_join = array('table' => 'products', 'alias' => 'Product', 'type' => 'INNER', 'conditions' => array('Product.category_id = Category.id', 'Product.vendor_id' => $vendor_id, 'Product.is_active' => '1', 'Product.is_deleted' => '0')); $Categorydata = $this->Category->find('all', array('fields' => array('Category.id,Category.title'), 'conditions' => array("Category.title <= {$price_coupon_limit}", 'Category.is_active' => '1', 'Category.is_deleted' => '0'), 'recursive' => 0, 'joins' => array($product_join))); $Categorydata = Set::extract('/Category/.', $Categorydata); $result = array_map("unserialize", array_unique(array_map("serialize", $Categorydata))); $counter = 0; foreach ($result as $key => $value) { $set_categorydata[$counter]['key'] = ENCRYPT_DATA($value['id']); $set_categorydata[$counter]['value'] = $value['title']; $counter++; } } } return json_encode($set_categorydata); break; } } } } } else { $this->redirect(array("controller" => "dashboards", "action" => "unauthorize", "admin" => true)); } }
function admin_edit_category($category_id = null) { $category_id = DECRYPT_DATA($category_id); $this->layout = 'backend/backend'; $this->set("title_for_layout", EDIT_CATEGORY); if (!empty($this->data)) { $data = $this->data; $data['Category']['id'] = DECRYPT_DATA($data['Category']['id']); $errors = $this->Category->validate_add_category($data['Category']); if (count($errors) == 0) { if ($this->Category->save($data)) { $this->Session->setFlash(RECORD_SAVE, 'message/green'); $this->redirect(array("controller" => "categories", "action" => "listing", "admin" => true)); } else { $this->Session->setFlash(RECORD_ERROR, 'message/red'); $this->redirect(array("controller" => "categories", "action" => "edit_category", $this->data['Category']['id'], "admin" => true)); } } else { $this->set("errors", $errors); } } else { if (isset($category_id)) { if ($this->is_id_exist($category_id, "Category")) { $this->Category->id = $category_id; $data = $this->Category->read(); $data['Category']['id'] = ENCRYPT_DATA($data['Category']['id']); $this->data = $data; } else { $this->Session->setFlash(NOT_FOUND_ERROR, 'message/red'); $this->redirect(array("controller" => "categories", 'action' => 'listing', 'admin' => true)); exit; } } } }
function admin_validate_edit_cms_ajax() { $this->layout = ""; $this->autoRender = false; if ($this->RequestHandler->isAjax()) { $errors_msg = null; App::import('Model', 'CmsPage'); $this->CmsPage = new CmsPage(); $data = $this->data; if (isset($data['CmsPage']['id'])) { $data['CmsPage']['id'] = DECRYPT_DATA($data['CmsPage']['id']); } $errors = $this->CmsPage->valid_edit_cms($data); if (is_array($this->data)) { foreach ($this->data['CmsPage'] as $key => $value) { if (array_key_exists($key, $errors)) { foreach ($errors[$key] as $k => $v) { $errors_msg .= "error|{$key}|{$v}"; } } else { $errors_msg .= "ok|{$key}\n"; } } } echo $errors_msg; die; } }
function admin_batch_popup($batch_id = null) { $this->layout = ""; $coupon_data = array(); if (!empty($batch_id) && $this->RequestHandler->isAjax()) { $batch_id = DECRYPT_DATA($batch_id); $conditions = array('Coupon.batch_id' => $batch_id); App::import("Model", "Coupon"); $this->Coupon = new Coupon(); $this->paginate = array('recursive' => -1, 'limit' => 10, 'conditions' => $conditions, 'order' => array("Coupon.expire_date" => "desc")); $this->set('coupon_data', $this->paginate('Coupon')); } else { $this->redirect(array("controller" => "dashboards", "action" => "unauthorize", "admin" => true)); } //$this->set('coupon_data',$coupon_data); }
function admin_edit_product($product_id = null) { $product_id = DECRYPT_DATA($product_id); $this->layout = 'backend/backend'; $this->set("title_for_layout", EDIT_PRODUCT); $category_list = $this->find_categories_list(); $this->set("category_list", $category_list); $vendor_list = $this->find_vendor_listing(); $this->set("vendor_list", $vendor_list); if (!empty($this->data)) { $data = $this->data; $data['Product']['id'] = DECRYPT_DATA($data['Product']['id']); $errors = $this->Product->validate_add_product($data['Product']); if (count($errors) == 0) { $voucher_value['Category']['title'] = $data["Product"]['voucher_value']; App::import("Model", "Category"); $this->Category = new Category(); $check_title = $this->Category->find('first', array("recursive" => -1, "fields" => array("id"), "conditions" => array("Category.title" => $voucher_value['Category']['title']))); if (!empty($check_title)) { $data["Product"]['category_id'] = $check_title['Category']['id']; } else { $this->Category->save($voucher_value); $data["Product"]['category_id'] = $this->Category->getLastInsertId(); } if ($this->Product->save($data)) { $this->Session->setFlash(RECORD_SAVE, 'message/green'); $this->redirect(array("controller" => "products", "action" => "listing", "admin" => true)); } else { $this->Session->setFlash(RECORD_ERROR, 'message/red'); $this->redirect(array("controller" => "products", "action" => "edit_product", $this->data['Product']['id'], "admin" => true)); } } else { $this->set("errors", $errors); } } else { if (isset($product_id)) { if ($this->is_id_exist($product_id, "Product")) { $this->Product->id = $product_id; $this->Product->recursive = -1; $data = $this->Product->read(); $data['Product']['id'] = ENCRYPT_DATA($data['Product']['id']); $this->data = $data; } else { $this->Session->setFlash(NOT_FOUND_ERROR, 'message/red'); $this->redirect(array("controller" => "products", 'action' => 'listing', 'admin' => true)); exit; } } } }