Example #1
0
function registerUser()
{
    $seller_name = $_REQUEST['seller_name'];
    $seller_username = $_REQUEST['seller_username'];
    $seller_password = $_REQUEST['seller_password'];
    $seller_phone = $_REQUEST['seller_phone'];
    $seller_type = $_REQUEST['seller_type'];
    $admin_password = $_REQUEST['admin_password'];
    include_once "../model/Seller.php";
    $seller = new Seller();
    $adduser = $seller->addShopKeeper($seller_name, $seller_username, $seller_password, $seller_phone, $seller_type, $admin_password);
    if ($adduser == "wrong admin password!") {
        echo '{"result": 0, "message": "' . $adduser . '"}';
        return;
    }
    if ($adduser == "existing username") {
        echo '{"result": 0, "message": "' . $adduser . '"}';
        return;
    }
    if ($adduser) {
        echo '{"result": 1, "message": "You successfully added ' . $seller_name . ' as a ' . $seller_type . '"}';
        return;
    }
    echo '{"result": 0, "Failed to add ' . $seller_name . ' as ' . $seller_type . '"}';
    return;
}
Example #2
0
 public function testGetNameReturnsFullNameIfNoCompanyNameGiven()
 {
     $client = new Seller();
     $client->setFirstName('Testowy');
     $client->setLastName('Test');
     $this->assertEquals('Testowy Test', $client->getName());
 }
Example #3
0
 /**
  * Attempts to get a customer product option from a given ID.
  *
  * @param int $id Customer product option ID.
  *
  * @return Model_Customer_Product_Option
  */
 protected function get_option($id)
 {
     $option = Service_Customer_Product_Option::find_one(array('id' => $id, 'status' => 'all'));
     if (!$option || $option->customer->seller != Seller::active()) {
         throw new HttpNotFoundException();
     }
     return $option;
 }
 public function listOfSellerCreationCakes()
 {
     $findUsers = Seller::all();
     $findUsers = $_SESSION['userFbID'];
     $cakes = Cake::where('userFbId', '=', $findUsers)->get();
     $user = User::where('fbId', '=', $_SESSION['userFbID'])->get();
     return View::make('myaccountSeller', ['cakes' => $cakes, 'user' => $user]);
 }
Example #5
0
 public function action_index()
 {
     $args = array('seller' => Seller::active());
     $pagination = Pagination::forge('customer_pagination', array('total_items' => Service_Customer_Order::count($args)));
     $orders = Service_Customer_Order::find(array_merge($args, array('offset' => $pagination->offset, 'limit' => $pagination->per_page, 'order_by' => array('updated_at' => 'desc'))));
     $this->view->orders = $orders;
     $this->view->pagination = $pagination;
 }
Example #6
0
 /**
  * Attempts to get a customer from a given ID.
  *
  * @param int $id Customer ID.
  *
  * @return Model_Customer
  */
 protected function get_customer($id)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $customer = Service_Customer::find_one(array('id' => $id, 'status' => 'all'));
     if (!$customer || $customer->seller != Seller::active()) {
         throw new HttpNotFoundException();
     }
     return $customer;
 }
Example #7
0
 /**
  * Attempts to get a customer from a given ID.
  *
  * @param int $id Customer ID.
  *
  * @return \Model_Customer
  */
 protected function get_customer($id)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $customer = \Service_Customer::find_one($id);
     if (!$customer || $customer->seller != \Seller::active()) {
         throw new HttpNotFoundException();
     }
     return $customer;
 }
Example #8
0
 /**
  * Attempts to get a contact from a given ID.
  *
  * @param int $id Contact ID.
  *
  * @return Model_Contact
  */
 protected function get_contact($customer_id, $id)
 {
     $customer = $this->get_customer($customer_id);
     if ($customer->seller != Seller::active()) {
         throw new HttpNotFoundException();
     }
     $contact = Service_Contact::find_one($id);
     if (!$contact || $contact != Service_Contact::primary($customer)) {
         throw new HttpNotFoundException();
     }
     return $contact;
 }
Example #9
0
 /**
  * Switches the active seller.
  * 
  * @param int $id Seller ID.
  *
  * @return void
  */
 public function action_switch($id = null)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $seller = Service_Seller::find_one($id);
     if (!$seller) {
         throw new HttpNotFoundException();
     }
     Seller::set($seller);
     Session::set_alert('success', "You are now viewing as seller \"{$seller->name}\".");
     Response::redirect('/');
 }
Example #10
0
 /**
  * Gets customer conversion statistics.
  *
  * @return void
  */
 public function get_conversion()
 {
     $names = array('total', 'total_active', 'total_subscribed');
     $statistics = \Service_Statistic::recent(array('seller' => \Seller::active(), 'type' => 'customer', 'name' => $names));
     $data = array();
     foreach ($statistics as $stat) {
         $date = $stat->date;
         $data[$date][$stat->name] = (int) $stat->value;
     }
     if (!empty($data)) {
         ksort($data[$date]);
     }
     $this->response($data);
 }
Example #11
0
 /**
  * Deletes a seller API key.
  *
  * @param int $id API key.
  *
  * @return void
  */
 public function action_delete($id = null)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $key = Service_Api_Key::find_one($id);
     if (!$key || $key->seller != Seller::active()) {
         throw new HttpNotFoundException();
     }
     if (!Service_Api_Key::delete($key)) {
         Session::set_alert('error', 'There was an error removing the API key.');
     } else {
         Session::set_alert('success', 'The API key has been removed.');
     }
     Response::redirect('settings/api');
 }
 /**
  *
  * @param Seller $seller
  * @return type
  * @throws DaoException 
  */
 public function updateSeller(Seller $seller)
 {
     try {
         $query = Doctrine_Query::create()->update('Seller i');
         $query->set('i.name', '?', $seller->getName());
         $query->set('i.address', '?', $seller->getAddress());
         $query->set('i.tp_hp', '?', $seller->getTpHp());
         $query->set('i.tp_home', '?', $seller->getTpHome());
         $query->set('i.notes', '?', $seller->getNotes());
         $query->where('i.id = ?', $seller->getId());
         return $query->execute();
     } catch (Exception $e) {
         throw new DaoException($e->getMessage(), $e->getCode(), $e);
     }
 }
Example #13
0
 /**
  * Gets one or more customer product options.
  *
  * @param int $customer_id Customer ID.
  * @param int $id          Product option ID.
  *
  * @return void
  */
 public function get_index($customer_id = null, $id = null)
 {
     if (!$customer_id) {
         throw new HttpNotFoundException();
     }
     $customer = \Service_Customer::find_one($customer_id);
     if (!$customer || $customer->seller != \Seller::active()) {
         throw new HttpNotFoundException();
     }
     if (!$id) {
         $products = \Service_Customer_Product_Option::find(array('customer' => $customer));
     } else {
         $products = \Service_Customer_Product_Option::find_one($id);
         if (!$products || $products->customer != $customer) {
             throw new HttpNotFoundException();
         }
     }
     $this->response($products);
 }
Example #14
0
 /**
  * Updates a seller.
  *
  * @param int $id Seller ID.
  *
  * @return void
  */
 public function put_index($id = null)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $seller = \Service_Seller::find_one($id);
     if (!$seller || $seller != \Seller::active()) {
         throw new HttpNotFoundException();
     }
     $validator = \Validation_Seller::update();
     if (!$validator->run(\Input::put())) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $seller = \Service_Seller::update($seller, $data);
     if (!$seller) {
         throw new HttpServerErrorException();
     }
     $this->response($seller);
 }
Example #15
0
 public function saveCake()
 {
     // validate
     $rules = array('name' => 'required', 'price' => 'required', 'category' => 'required', 'description' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('addCake')->withErrors($validator);
     } else {
         //IMAGEUPLOAD
         $image = Input::file('image');
         if ($image) {
             $upload_folder = '/img/upload/';
             $file_name = str_random(30) . '.' . $image->getClientOriginalExtension();
             $image->move(public_path() . $upload_folder, $file_name);
         }
         ///
         // store
         $cake = new Cake();
         $cake->name = Input::get('name');
         $cake->price = Input::get('price');
         $cake->category = Input::get('category');
         $cake->description = Input::get('description');
         $seller = new Seller();
         $findUser = Seller::all();
         $findUser = $_SESSION['userFbID'];
         //$seller = Seller::orderBy('created_at', 'desc')->first();
         //$fbId = $seller['fbId'];
         $cake->userFbId = $findUser;
         //IMAGEUPLOAD
         if ($image) {
             $cake->image = $file_name;
         }
         ///////
         $cake->save();
         // redirect
         Session::flash('message', 'Successfully created Product!');
         return Redirect::to('myaccountSeller');
     }
 }
 public function listOfSellers()
 {
     $seller = Seller::all();
     $user = User::where('fbId', '=', $_SESSION['userFbID'])->get();
     return View::make('singlepageSeller', ['seller' => $seller, 'user' => $user]);
 }
Example #17
0
 /**
  * Checks for api key authentication.
  *
  * @return bool
  */
 protected function _prepare_key_auth()
 {
     // Skip auth for front-end interface.
     if (\Seller::active()) {
         return true;
     }
     \Config::load('api', true);
     $api_key = \Input::param('api_key', \Config::get('api.key'));
     if (!$api_key) {
         return false;
     }
     $api_key = \Service_Api_Key::find_one(array('key' => $api_key));
     if (!$api_key) {
         return false;
     }
     if ($api_key->seller) {
         \Seller::set($api_key->seller);
     }
     return true;
 }
Example #18
0
 /**
  * Deletes a product.
  *
  * @param int $id Product ID.
  *
  * @return void
  */
 public function delete_index($id = null)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $product = \Service_Product::find_one($id, \Seller::active());
     if (!$product || $product->seller != \Seller::active()) {
         throw new HttpNotFoundException();
     }
     $deleted = \Service_Product::delete($product);
     if (!$deleted) {
         throw new HttpServerErrorException();
     }
 }
<?php

include '../include/adminheader.php';
include_once '../model/dbconnect.php';
include '../model/processaccount.php';
include '../model/seller.php';
$msg_register = 0;
if (isset($_POST['btn-edit'])) {
    $users = new User();
    $seller = new Seller();
    $processaccount = new Processaccount();
    $users->setFullname(mysql_real_escape_string($_POST['fname']));
    $users->setUsername(mysql_real_escape_string($_POST['uname']));
    $users->setEmail(mysql_real_escape_string($_POST['email']));
    $users->setPhone(mysql_real_escape_string($_POST['phone']));
    $seller->setCompany(mysql_real_escape_string($_POST['company']));
    $seller->setAddress(mysql_real_escape_string($_POST['address']));
    $seller->setCity(mysql_real_escape_string($_POST['city']));
    $seller->setPostalcode(mysql_real_escape_string($_POST['postalcode']));
    $seller->setDescription(mysql_real_escape_string($_POST['description']));
    $objs = array();
    $objs[] = $users;
    $objs[] = $seller;
    $msg_register = $processaccount->editAdminProfile($objs);
    if ($msg_register == 0) {
        header("Location: adminaccount.php");
    }
}
?>

	
Example #20
0
 /**
  * Attempts to get a contact from a given ID.
  *
  * @param int $id Contact ID.
  *
  * @return Model_Contact
  */
 protected function get_contact($id)
 {
     $contact = Service_Contact::find_one($id);
     if (!$contact || !in_array($contact, Seller::active()->contacts)) {
         throw new HttpNotFoundException();
     }
     return $contact;
 }
Example #21
0
 /**
  * Attempts to get a product option from a given ID.
  *
  * @param int $id Product option ID.
  *
  * @return Model_Product_Option
  */
 protected function get_option($id)
 {
     $option = Service_Product_Option::find_one($id);
     if (!$option || $option->product->seller != Seller::active()) {
         throw new HttpNotFoundException();
     }
     return $option;
 }
Example #22
0
Casset::less('less/layouts/default/config.less', true, 'base');
Casset::less('less/layouts/default/layout.less', true, 'base');
Casset::less('less/layouts/default/config.less', true, 'page');
Casset::js('libs/jquery/jquery.min.js', false, 'base');
Casset::js('libs/jquery/plugins/jquery.validate.js', true, 'page');
Casset::js('libs/bootstrap/js/bootstrap-alert.js', true, 'base');
Casset::js('libs/bootstrap/js/bootstrap-modal.js', true, 'base');
Casset::js('libs/bootstrap/js/bootstrap-transition.js', true, 'base');
Casset::js('libs/bootstrap/plugins/bootbox/bootbox.js', true, 'base');
Casset::js('libs/bootstrap/plugins/bootstrap-hover-dropdown.js', true, 'base');
Casset::js('js/common.js', true, 'base');
Casset::js('js/common/common.validate.js', true, 'page');
$app_name = Config::get('app_name');
$seller = Seller::active();
$sellers = Seller::all();
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>
		<?php 
echo $app_name;
?>
		<?php 
if (!empty($title) && empty($breadcrumbs)) {
    ?>
			- <?php 
    echo $title;
Example #23
0
 /**
  * Attempts to get a product meta option from a given ID.
  *
  * @param int                 $id   Product meta option ID.
  * @param \Model_Product_Meta $meta Product meta the option should belong to.
  *
  * @return \Model_Product_Meta_Option
  */
 protected function get_option($id, \Model_Product_Meta $meta)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $option = \Service_Product_Meta_Option::find_one($id);
     if (!$option || $option->meta != $meta || $option->meta->product->seller != \Seller::active()) {
         throw new HttpNotFoundException();
     }
     return $option;
 }
Example #24
0
 /**
  * Attempts to get a product from a given ID.
  *
  * @param int $id Product ID.
  *
  * @return Model_Product
  */
 protected function get_product($id)
 {
     $product = Service_Product::find_one($id);
     if (!$product || $product->seller != Seller::active()) {
         throw new HttpNotFoundException();
     }
     return $product;
 }
Example #25
0
 /**
  * Attempts to get a product option fee from a given ID.
  *
  * @param int $id Product option fee ID.
  *
  * @return Model_Product_Option_Fee
  */
 protected function get_fee($id)
 {
     $fee = Service_Product_Option_Fee::find_one($id);
     if (!$fee || $fee->option->product->seller != Seller::active()) {
         throw new HttpNotFoundException();
     }
     return $fee;
 }
Example #26
0
 /**
  * Attempts to get a product meta from a given ID.
  *
  * @param int $id Product meta ID.
  *
  * @return Model_Product_Meta
  */
 protected function get_meta($id)
 {
     $meta = Service_Product_Meta::find_one($id);
     if (!$meta || $meta->product->seller != Seller::active()) {
         throw new HttpNotFoundException();
     }
     return $meta;
 }
Example #27
0
 /**
  * Attempts to get a seller's primary gateway.
  *
  * @return Model_Gateway
  */
 public function get_gateway()
 {
     $gateway = Service_Gateway::find_one(array('seller' => Seller::active()));
     if (!$gateway) {
         throw new HttpNotFoundException();
     }
     return $gateway;
 }
Example #28
0
 /**
  * Attempts to get a payment method from a given ID.
  *
  * @param int             $id       Payment method ID.
  * @param \Model_Customer $customer Customer the payment method should belong to.
  *
  * @return \Model_Customer_Paymentmethod
  */
 protected function get_paymentmethod($id, \Model_Customer $customer)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $payment_method = \Service_Customer_Paymentmethod::find_one($id);
     if (!$payment_method || $payment_method->customer != $customer || $payment_method->customer->seller != \Seller::active()) {
         throw new HttpNotFoundException();
     }
     return $payment_method;
 }
Example #29
0
 /**
  * Attempts to get a seller callback from a given ID.
  *
  * @param int $id Seller callback ID.
  *
  * @return Model_Seller_Callback
  */
 protected function get_callback($id)
 {
     $callback = Service_Seller_Callback::find_one(array('id' => $id, 'seller' => Seller::active()));
     if (!$callback) {
         throw new HttpNotFoundException();
     }
     return $callback;
 }
Example #30
0
 /**
  * Attempts to get a gateway from a given ID.
  *
  * @param int $id Gateway ID.
  *
  * @return \Model_Gateway
  */
 protected function get_gateway($id)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $gateway = \Service_Gateway::find_one(array('id' => $id, 'seller' => \Seller::active()));
     if (!$gateway) {
         throw new HttpNotFoundException();
     }
     return $gateway;
 }