예제 #1
0
	function save () {
		parent::save();

		if (empty($this->info) || !is_array($this->info)) return true;
		foreach ((array)$this->info as $name => $value) {
			$Meta = new MetaObject(array(
				'parent' => $this->id,
				'context' => 'customer',
				'type' => 'meta',
				'name' => $name
			));
			$Meta->parent = $this->id;
			$Meta->context = 'customer';
			$Meta->type = 'meta';
			$Meta->name = $name;
			$Meta->value = $value;
			$Meta->save();
		}
	}
예제 #2
0
파일: Meta.php 프로젝트: robbiespire/paQui
	/**
	 * Saves updates or creates records for the defined object properties
	 *
	 * @since 1.1
	 *
	 * @return void Description...
	 **/
	function save () {
		$db = &DB::get();

		if (empty($this->id)) {
			$meta = new MetaObject();
			$meta->parent = 0;
			$meta->context = $this->_context;
			$meta->type = $this->_type;
			$meta->name = 'id';
			$meta->value = $meta->save();
			$this->_parent = $meta->value;
			$this->id = $meta->value;
			$this->_meta['id'] = $meta;
		}

		// Go through each data property of the object
		foreach(get_object_vars($this) as $property => $value) {
			if ($property[0] == "_") continue; // Skip mapping properties
			if (!isset($this->_meta[$property])) {
				$meta = new MetaObject();
				$meta->parent = $this->_parent;
				$meta->context = $this->_context;
				$meta->type = $this->_type;
				$meta->name = $property;
				$meta->value = $value;
				$this->_meta[$property] = $meta;
			} else $this->_meta[$property]->value = $value;
			$this->_meta[$property]->save();
		}

	}
예제 #3
0
	/**
	 * Interface processor for the customer list screen
	 *
	 * Handles processing customer list actions and displaying the
	 * customer list screen
	 * 
	 * @return void
	 **/
	function customers () {
		global $Ecart,$Customers,$wpdb;
		$db = DB::get();

		$defaults = array(
			'page' => false,
			'deleting' => false,
			'selected' => false,
			'update' => false,
			'newstatus' => false,
			'pagenum' => 1,
			'per_page' => false,
			'start' => '',
			'end' => '',
			'status' => false,
			's' => '',
			'range' => '',
			'startdate' => '',
			'enddate' => '',
		);

		$args = array_merge($defaults,$_GET);
		extract($args, EXTR_SKIP);

		if ($page == $this->Admin->pagename('customers')
				&& !empty($deleting)
				&& !empty($selected)
				&& is_array($selected)
				&& current_user_can('ecart_delete_customers')) {
			foreach($selected as $deletion) {
				$Customer = new Customer($deletion);
				$Billing = new Billing($Customer->id,'customer');
				$Billing->delete();
				$Shipping = new Shipping($Customer->id,'customer');
				$Shipping->delete();
				$Customer->delete();
			}
		}

		if (!empty($_POST['save'])) {
			check_admin_referer('ecart-save-customer');

			if ($_POST['id'] != "new") {
				$Customer = new Customer($_POST['id']);
				$Billing = new Billing($Customer->id,'customer');
				$Shipping = new Shipping($Customer->id,'customer');
			} else $Customer = new Customer();

			$Customer->updates($_POST);

			if (!empty($_POST['new-password']) && !empty($_POST['confirm-password'])
				&& $_POST['new-password'] == $_POST['confirm-password']) {
					$Customer->password = wp_hash_password($_POST['new-password']);
					if (!empty($Customer->wpuser)) wp_set_password($_POST['new-password'], $Customer->wpuser);
				}

			$Customer->info = false; // No longer used from DB
			$Customer->save();

			foreach ($_POST['info'] as $id => $info) {
				$Meta = new MetaObject($id);
				$Meta->value = $info;
				$Meta->save();
			}

			if (isset($Customer->id)) $Billing->customer = $Customer->id;
			$Billing->updates($_POST['billing']);
			$Billing->save();

			if (isset($Customer->id)) $Shipping->customer = $Customer->id;
			$Shipping->updates($_POST['shipping']);
			$Shipping->save();

		}

		$pagenum = absint( $pagenum );
		if ( empty($pagenum) )
			$pagenum = 1;
		if( !$per_page || $per_page < 0 )
			$per_page = 20;
		$index = ($per_page * ($pagenum-1));

		if (!empty($start)) {
			$startdate = $start;
			list($month,$day,$year) = explode("/",$startdate);
			$starts = mktime(0,0,0,$month,$day,$year);
		}
		if (!empty($end)) {
			$enddate = $end;
			list($month,$day,$year) = explode("/",$enddate);
			$ends = mktime(23,59,59,$month,$day,$year);
		}

		$customer_table = DatabaseObject::tablename(Customer::$table);
		$billing_table = DatabaseObject::tablename(Billing::$table);
		$purchase_table = DatabaseObject::tablename(Purchase::$table);
		$users_table = $wpdb->users;

		$where = '';
		if (!empty($s)) {
			$s = stripslashes($s);
			if (preg_match_all('/(\w+?)\:(?="(.+?)"|(.+?)\b)/',$s,$props,PREG_SET_ORDER)) {
				foreach ($props as $search) {
					$keyword = !empty($search[2])?$search[2]:$search[3];
					switch(strtolower($search[1])) {
						case "company": $where .= ((empty($where))?"WHERE ":" AND ")."c.company LIKE '%$keyword%'"; break;
						case "login": $where .= ((empty($where))?"WHERE ":" AND ")."u.user_login LIKE '%$keyword%'"; break;
						case "address": $where .= ((empty($where))?"WHERE ":" AND ")."(b.address LIKE '%$keyword%' OR b.xaddress='%$keyword%')"; break;
						case "city": $where .= ((empty($where))?"WHERE ":" AND ")."b.city LIKE '%$keyword%'"; break;
						case "province":
						case "state": $where .= ((empty($where))?"WHERE ":" AND ")."b.state='$keyword'"; break;
						case "zip":
						case "zipcode":
						case "postcode": $where .= ((empty($where))?"WHERE ":" AND ")."b.postcode='$keyword'"; break;
						case "country": $where .= ((empty($where))?"WHERE ":" AND ")."b.country='$keyword'"; break;
					}
				}
			} elseif (strpos($s,'@') !== false) {
				 $where .= ((empty($where))?"WHERE ":" AND ")."c.email='$s'";
			} else $where .= ((empty($where))?"WHERE ":" AND ")." (c.id='$s' OR CONCAT(c.firstname,' ',c.lastname) LIKE '%$s%' OR c.company LIKE '%$s%')";

		}
		if (!empty($starts) && !empty($ends)) $where .= ((empty($where))?"WHERE ":" AND ").' (UNIX_TIMESTAMP(c.created) >= '.$starts.' AND UNIX_TIMESTAMP(c.created) <= '.$ends.')';

		$customercount = $db->query("SELECT count(*) as total FROM $customer_table AS c $where");
		$query = "SELECT c.*,b.city,b.state,b.country, u.user_login, SUM(p.total) AS total,count(distinct p.id) AS orders FROM $customer_table AS c LEFT JOIN $purchase_table AS p ON p.customer=c.id LEFT JOIN $billing_table AS b ON b.customer=c.id LEFT JOIN $users_table AS u ON u.ID=c.wpuser AND (c.wpuser IS NULL OR c.wpuser !=0) $where GROUP BY c.id ORDER BY c.created DESC LIMIT $index,$per_page";
		$Customers = $db->query($query,AS_ARRAY);

		$num_pages = ceil($customercount->total / $per_page);
		$page_links = paginate_links( array(
			'base' => add_query_arg( 'pagenum', '%#%' ),
			'format' => '',
			'total' => $num_pages,
			'current' => $pagenum
		));

		$ranges = array(
			'all' => __('Show New Customers','Ecart'),
			'today' => __('Today','Ecart'),
			'week' => __('This Week','Ecart'),
			'month' => __('This Month','Ecart'),
			'quarter' => __('This Quarter','Ecart'),
			'year' => __('This Year','Ecart'),
			'yesterday' => __('Yesterday','Ecart'),
			'lastweek' => __('Last Week','Ecart'),
			'last30' => __('Last 30 Days','Ecart'),
			'last90' => __('Last 3 Months','Ecart'),
			'lastmonth' => __('Last Month','Ecart'),
			'lastquarter' => __('Last Quarter','Ecart'),
			'lastyear' => __('Last Year','Ecart'),
			'lastexport' => __('Last Export','Ecart'),
			'custom' => __('Custom Dates','Ecart')
			);

		$exports = array(
			'tab' => __('Tab-separated.txt','Ecart'),
			'csv' => __('Comma-separated.csv','Ecart'),
			'xls' => __('Microsoft&reg; Excel.xls','Ecart')
			);


		$formatPref = $Ecart->Settings->get('customerexport_format');
		if (!$formatPref) $formatPref = 'tab';

		$columns = array_merge(Customer::exportcolumns(),Billing::exportcolumns(),Shipping::exportcolumns());
		$selected = $Ecart->Settings->get('customerexport_columns');
		if (empty($selected)) $selected = array_keys($columns);

		$authentication = $Ecart->Settings->get('account_system');

		include(ECART_ADMIN_PATH."/customers/customers.php");

	}
예제 #4
0
파일: Asset.php 프로젝트: robbiespire/paQui
	/**
	 * Save the object back to the database
	 * 
	 * @since 1.1
	 *
	 * @return void
	 **/
	function save () {
		$this->value = new stdClass();
		foreach ($this->_xcols as $col)
			$this->value->{$col} = $this->{$col};
		parent::save();
	}
예제 #5
0
	/**
	 * Interface processor for the order manager
	 *	 
	 * @return void
	 **/
	function manager () {
		global $Ecart,$UI,$Notes;
		global $is_IIS;

		if ( !(is_ecart_userlevel() || current_user_can('ecart_orders')) )
			wp_die(__('You do not have sufficient permissions to access this page.','Ecart'));

		$Purchase = $Ecart->Purchase;
		$Purchase->Customer = new Customer($Purchase->customer);

		// Handle Order note processing
		if (!empty($_POST['note'])) {
			$user = wp_get_current_user();
			$Note = new MetaObject();
			$Note->parent = $Purchase->id;
			$Note->context = 'purchase';
			$Note->type = 'order_note';
			$Note->name = 'note';
			$Note->value = new stdClass();
			$Note->value->author = $user->ID;
			$Note->value->message = $_POST['note'];
			$Note->save();
		}
		if (!empty($_POST['delete-note'])) {
			$noteid = key($_POST['delete-note']);
			$Note = new MetaObject($noteid);
			$Note->delete();
		}
		if (!empty($_POST['edit-note'])) {
			$noteid = key($_POST['note-editor']);
			$Note = new MetaObject($noteid);
			$Note->value->message = $_POST['note-editor'][$noteid];
			$Note->save();
		}
		$Notes = new ObjectMeta($Purchase->id,'purchase','order_note');

		if (!empty($_POST['update'])) {
			check_admin_referer('ecart-save-order');

			if ($_POST['txnstatus'] != $Purchase->txnstatus)
				do_action_ref_array('ecart_order_txnstatus_update',array(&$_POST['txnstatus'],&$Purchase));


			$Purchase->updates($_POST);

			$mailstatus = false;
			if ($_POST['notify'] == "yes") {
				$labels = $this->Settings->get('order_status');
				// Save a reference to this purchase in Ecart
				// so the Template API works when generating the receipt
				$Ecart->Purchase =& $Purchase;

				// Send the e-mail notification
				$addressee = "$Purchase->firstname $Purchase->lastname";
				$address = "$Purchase->email";

				$email = array();
				$email['from'] = '"'.get_bloginfo("name").'"';
				if ($Ecart->Settings->get('merchant_email'))
					$email['from'] .= ' <'.$Ecart->Settings->get('merchant_email').'>';
				if($is_IIS) $email['to'] = $address;
				else $email['to'] = '"'.html_entity_decode($addressee,ENT_QUOTES).'" <'.$address.'>';
				$email['subject'] = __('Order Updated','Ecart');
				$email['url'] = get_bloginfo('siteurl');
				$email['sitename'] = get_bloginfo('name');

				if ($_POST['receipt'] == "yes")
					$email['receipt'] = $Purchase->receipt();

				$email['status'] = strtoupper($labels[$Purchase->status]);
				$email['message'] = wpautop(stripslashes($_POST['message']));

				if (file_exists(ECART_TEMPLATES."/notification.html")) $template = ECART_TEMPLATES."/notification.html";
				if (file_exists(ECART_TEMPLATES."/notify.php")) $template = ECART_TEMPLATES."/notify.php";

				if (ecart_email($template,$email)) $mailsent = true;

			}

			$Purchase->save();
			if ($mailsent) $updated = __('Order status updated & notification email sent.','Ecart');
			else $updated = __('Order status updated.','Ecart');
		}

		$targets = $this->Settings->get('target_markets');
		$UI->txnStatusLabels = Lookup::payment_status_labels();
		$UI->statusLabels = $this->Settings->get('order_status');
		if (empty($statusLabels)) $statusLabels = array('');

		include(ECART_ADMIN_PATH."/orders/order.php");
	}
예제 #6
0
파일: Main.php 프로젝트: TakenCdosG/chefs
 /**
  * Adds an order note to record that the tickets email was resent.
  *
  * @param Purchase $order
  */
 protected function add_tickets_resent_note($order_id)
 {
     $Note = new MetaObject();
     $Note->parent = $order_id;
     $Note->context = 'purchase';
     $Note->type = 'order_note';
     $Note->name = 'note';
     $Note->value = new stdClass();
     $Note->value->author = wp_get_current_user()->ID;
     $Note->value->message = __('Email containing tickets (sent by ShoppTickets)', 'event-tickets-plus');
     $Note->value->sent = true;
     $Note->save();
 }