อยากทำให้ช่องใส่ตัวเลขพิมพ์เป็นตัวหนังสือได้ด้วย

กฎการใช้บอร์ด
คำถามหมวดนี้ ควรระบุ รายละเอียดของ Server OS, เวอร์ชั่น ของ PHP, CMS ที่ท่านใช้
รวมถึง Hosting หรือ Control Panel Hosting

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: อยากทำให้ช่องใส่ตัวเลขพิมพ์เป็นตัวหนังสือได้ด้วย

Re: อยากทำให้ช่องใส่ตัวเลขพิมพ์เป็นตัวหนังสือได้ด้วย

โดย mindphp » 15/06/2009 11:33 am

ดีใจด้วยครับ :-D
เอามาแบ่งบันคนอื่นหน่อยก็ดีนะครับ

Re: อยากทำให้ช่องใส่ตัวเลขพิมพ์เป็นตัวหนังสือได้ด้วย

โดย or_neung » 15/06/2009 8:27 am

ลองทำดูแล้ว
ปรากฎว่าได้เเล้วค่า
ขอบคุณมากนะคะ :-D

Re: อยากทำให้ช่องใส่ตัวเลขพิมพ์เป็นตัวหนังสือได้ด้วย

โดย mindphp » 12/06/2009 6:21 pm

ให้เอา function intval() ออกไป ครับ

Re: อยากทำให้ช่องใส่ตัวเลขพิมพ์เป็นตัวหนังสือได้ด้วย

โดย or_neung » 11/06/2009 9:49 am

มีมาให้ดูอีกอันนึ่งค่า
คิดว่าน่าจะเกี่ยวกัน
ช่วยหน่อยนะคะ

โค้ด: เลือกทั้งหมด

// ADD A PRICE, IF NOT EMPTY ADD 0
		if (!empty($d['product_price'])) {

			if(empty($d['product_currency']))
			$d['product_currency'] = $_SESSION['vendor_currency'];

			$d["price_quantity_start"] = 0;
			$d["price_quantity_end"] = "";
			require_once ( CLASSPATH. 'ps_product_price.php');
			$my_price = new ps_product_price;
			$my_price->add($d);
		}

Re: อยากทำให้ช่องใส่ตัวเลขพิมพ์เป็นตัวหนังสือได้ด้วย

โดย or_neung » 11/06/2009 9:20 am

ลองไปดูมาเเล้วค่ะ
รบกวนช่วยดูให้หน่อยนะคะ
คิดว่าน่าจะใช่

โค้ด: เลือกทั้งหมด

<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/**
*
* @version $Id: ps_product_price.php 617 2007-01-04 19:43:08Z soeren_nb $
* @package VirtueMart
* @subpackage classes
* @copyright Copyright (C) 2004-2005 Soeren Eberhardt. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/

/****************************************************************************
*
* CLASS DESCRIPTION
*
* ps_product_price
*
*************************************************************************/
class ps_product_price {
	var $classname = "ps_product_price";

	/**************************************************************************
	** name: validate()
	** created by:
	** description:
	** parameters:
	** returns:
	***************************************************************************/
	function validate(&$d) {
		$valid = true;
		$d["error"] = "";
		if (!isset($d["product_price"])) {
			$d["error"] .= "ERROR: A price must be entered.";
			$valid = false;
		}
		if (empty($d["product_id"])) {
			$d["error"] .= "ERROR: A product ID is missing.";
			$valid = false;
		}
		// convert all "," in prices to decimal points.
		if (stristr($d["product_price"],","))
		$d['product_price'] = str_replace(',', '.', $d["product_price"]);

		if (!$d["product_currency"]) {
			$d["error"] .= "ERROR: A currency must be entered.";
			$valid = false;
		}
		$d["price_quantity_start"] = intval($d["price_quantity_start"]);
		$d["price_quantity_end"] = intval($d["price_quantity_end"]);

		if ($d["price_quantity_end"] < $d["price_quantity_start"]) {
			$d["error"] .= "ERROR: The entered Quantity End is less than the Quantity Start.";
			$valid = false;
		}

		$db = new ps_DB;
		$q = "SELECT count(*) AS num_rows FROM #__{vm}_product_price WHERE";
		if (!empty($d["product_price_id"])) {
			$q .= " product_price_id != '".$d['product_price_id']."' AND";
		}
		$q .= " shopper_group_id = '".$d["shopper_group_id"]."'";
		$q .= " AND product_id = '".$d['product_id']."'";
		$q .= " AND product_currency = '".$d['product_currency']."'";
		$q .= " AND (('".$d['price_quantity_start']."' >= price_quantity_start AND '".$d['price_quantity_start']."' <= price_quantity_end)";
		$q .= " OR ('".$d['price_quantity_end']."' >= price_quantity_start AND '".$d['price_quantity_end']."' <= price_quantity_end))";
		$db->query( $q ); $db->next_record();

		if ($db->f("num_rows") > 0) {
			$d["error"] .= "ERROR: This product already has a price for the selected Shopper Group and the specified Quantity Range.";
			$valid = false;
		}
		return $valid;
	}

	/**************************************************************************
	** name: add()
	** created by:
	** description:
	** parameters:
	** returns:
	***************************************************************************/
	function add(&$d) {
		if (!$this->validate($d)) {
			return false;
		}

		$timestamp = time();
		if (empty($d["product_price_vdate"])) $d["product_price_vdate"] = '';
		if (empty($d["product_price_edate"])) $d["product_price_edate"] = '';

		$db = new ps_DB;
		$q  = "INSERT INTO #__{vm}_product_price (product_id,shopper_group_id,";
		$q .= "product_price,product_currency,product_price_vdate,";
		$q .= "product_price_edate,cdate,mdate,price_quantity_start,price_quantity_end) ";
		$q .= "VALUES ('" . $d["product_id"] . "','" . $d["shopper_group_id"];
		$q .= "','" . $d["product_price"] . "','" . $d["product_currency"] . "','";
		$q .= $d["product_price_vdate"] . "','" . $d["product_price_edate"] . "',";
		$q .= "'$timestamp','$timestamp', '".$d["price_quantity_start"]."','".$d["price_quantity_end"]."')";

		$db->query($q);

		return true;
	}

	/**************************************************************************
	** name: update()
	** created by:
	** description:
	** parameters:
	** returns:
	***************************************************************************/
	function update(&$d) {
		if (!$this->validate($d)) {
			return false;
		}

		$timestamp = time();

		$db = new ps_DB;
		if (empty($d["product_price_vdate"])) $d["product_price_vdate"] = '';
		if (empty($d["product_price_edate"])) $d["product_price_edate"] = '';

		$q  = "UPDATE #__{vm}_product_price SET ";
		$q .= "shopper_group_id='" . $d["shopper_group_id"] . "',";
		$q .= "product_id='" . $d["product_id"] . "',";
		$q .= "product_price='" . $d["product_price"] . "',";
		$q .= "product_currency='" . $d["product_currency"] . "',";
		$q .= "product_price_vdate='" . $d["product_price_vdate"] . "',";
		$q .= "product_price_edate='" . $d["product_price_edate"] . "',";
		$q .= "price_quantity_start='" . $d["price_quantity_start"] . "',";
		$q .= "price_quantity_end='" . $d["price_quantity_end"] . "',";
		$q .= "mdate='$timestamp' ";
		$q .= "WHERE product_price_id='" . $d["product_price_id"] . "' ";

		$db->query($q);

		return true;
	}

	/**
	* Controller for Deleting Records.
	*/
	function delete(&$d) {

		$record_id = $d["product_price_id"];

		if( is_array( $record_id)) {
			foreach( $record_id as $record) {
				if( !$this->delete_record( $record, $d ))
				return false;
			}
			return true;
		}
		else {
			return $this->delete_record( $record_id, $d );
		}
	}
	/**
	* Deletes one Record.
	*/
	function delete_record( $record_id, &$d ) {
		global $db;
		$q  = "DELETE FROM #__{vm}_product_price ";
		$q .= "WHERE product_price_id = '$record_id' ";
		$db->query($q);

		return True;
	}


}
?>

Re: อยากทำให้ช่องใส่ตัวเลขพิมพ์เป็นตัวหนังสือได้ด้วย

โดย or_neung » 10/06/2009 2:16 pm

ไม่แน่ใจว่าอันนี้ใช่หรือเปล่านะคะ
แนบไฟล์
php.rar
(69.3 KiB) ดาวน์โหลดแล้ว 391 ครั้ง

Re: อยากทำให้ช่องใส่ตัวเลขพิมพ์เป็นตัวหนังสือได้ด้วย

โดย or_neung » 10/06/2009 1:37 pm

ส่วนของคอมโพเน้นท์ virtuemart มีหลายเพจมากเลยค่ะ
เลยหาส่วนที่ insert เข้าไปไม่เจอ
ขอโทษด้วยนะค่ะ :(
ถ้าหาเจอเเล้ว
จะรบกวนอีกทีนะคะ

Re: อยากทำให้ช่องใส่ตัวเลขพิมพ์เป็นตัวหนังสือได้ด้วย

โดย mindphp » 10/06/2009 12:38 pm

มันอยู่ในส่วนของ Component ครับ
ถ้าจะแก้ต้องมีความรู้ php ครับ

Re: อยากทำให้ช่องใส่ตัวเลขพิมพ์เป็นตัวหนังสือได้ด้วย

โดย or_neung » 10/06/2009 11:24 am

ถ้าไม่ใช่หน้านี้ก็ขอโทษด้วยนะค่ะ
เพราะไม่ค่อยรู้เรื่องจริงๆ
ขอคำเเนะนำด้วยค่ะ

Re: อยากทำให้ช่องใส่ตัวเลขพิมพ์เป็นตัวหนังสือได้ด้วย

โดย or_neung » 10/06/2009 11:23 am

ขอโทษด้วยนะค่ะ
คือไม่เคยใช้นะค่ะ

พอลองกดเซฟเเล้วมันหน้า administrator/index2.php นะค่ะ
เลยลองเอาโค้ดหน้านี้มาให้ดู

<?php
/**
* @version $Id: index2.php 10041 2008-02-15 21:48:13Z eddieajau $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Set flag that this is a parent file
define( '_VALID_MOS', 1 );
if (!file_exists( '../configuration.php' )) {
header( 'Location: ../installation/index.php' );
exit();
}
require( '../globals.php' );
require( '../configuration.php' );
// SSL check - $http_host returns <live site url>:<port number if it is 443>
$http_host = explode(':', $_SERVER['HTTP_HOST'] );
if( (!empty( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) != 'off' || isset( $http_host[1] ) && $http_host[1] == 443) && substr( $mosConfig_live_site, 0, 8 ) != 'https://' ) {
$mosConfig_live_site = 'https://'.substr( $mosConfig_live_site, 7 );
}
require_once( $mosConfig_absolute_path . '/includes/joomla.php' );
include_once( $mosConfig_absolute_path . '/language/'. $mosConfig_lang .'.php' );
require_once( $mosConfig_absolute_path . '/administrator/includes/admin.php' );
// must start the session before we create the mainframe object
session_name( md5( $mosConfig_live_site ) );
session_start();
$option = strval( strtolower( mosGetParam( $_REQUEST, 'option', '' ) ) );
$task = strval( mosGetParam( $_REQUEST, 'task', '' ) );
// mainframe is an API workhorse, lots of 'core' interaction routines
$mainframe = new mosMainFrame( $database, $option, '..', true );
// admin session handling
$my = $mainframe->initSessionAdmin( $option, $task );
// initialise some common request directives
$act = strtolower( mosGetParam( $_REQUEST, 'act', '' ) );
$section = mosGetParam( $_REQUEST, 'section', '' );
$no_html = intval( mosGetParam( $_REQUEST, 'no_html', 0 ) );
$id = intval( mosGetParam( $_REQUEST, 'id', 0 ) );
$cur_template = $mainframe->getTemplate();
// default admin homepage
if ($option == '') {
$option = 'com_admin';
}
// set for overlib check
$mainframe->set( 'loadOverlib', false );
// precapture the output of the component
require_once( $mosConfig_absolute_path . '/editor/editor.php' );
ob_start();
if ($path = $mainframe->getPath( 'admin' )) {
require_once ( $path );
} else {
?>
<img src="images/joomla_logo_black.jpg" border="0" alt="<?php echo 'Joomla! Logo'; ?>" />
<br />
<?php
}
$_MOS_OPTION['buffer'] = ob_get_contents();
ob_end_clean();
initGzip();
// start the html output
if ($no_html == 0) {
// loads template file
if ( !file_exists( $mosConfig_absolute_path .'/administrator/templates/'. $cur_template .'/index.php' ) ) {
echo 'TEMPLATE '. $cur_template .' NOT FOUND' ;
} else {
require_once( $mosConfig_absolute_path .'/administrator/templates/'. $cur_template .'/index.php' );
}
} else {
mosMainBody_Admin();
}
// displays queries performed for page
if ($mosConfig_debug) {
echo $database->_ticker . ' queries executed';
echo '<pre>';
foreach ($database->_log as $k=>$sql) {
echo $k+1 . "\n" . $sql . '<hr />';
}
}
// if task action is 'save' or 'apply' redo session check
if ( $task == 'save' || $task == 'apply' ) {
$mainframe->initSessionAdmin( $option, '' );
}
doGzip();
?>

ข้างบน